package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.WorkflowProduct;
import com.qidianit.mes.pro.service.WorkflowProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @Author: YanJiRan
 * @Date: 2025/9/19 - 下午6:13
 */
@RestController
@RequestMapping("/workflowProduct")
public class WorkflowProductController {
    @Autowired
    private WorkflowProductService workflowProductService;
    @GetMapping("/page")
    public Result<PageInfo<WorkflowProduct>> list(WorkflowProduct workflowProduct, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size){
        return workflowProductService.selectList(workflowProduct,page,size);
    }

    @PostMapping("/add")
    public Result<WorkflowProduct> save(@RequestBody WorkflowProduct workflowProduct){
        return workflowProductService.saveWorkflowProduct(workflowProduct);
    }

    @GetMapping("{id}")
    public Result<WorkflowProduct> getByCode(@PathVariable("id") Long id){
        return workflowProductService.selectById(id);
    }

    @PutMapping("/update")
    public Result update(@RequestBody WorkflowProduct workflowProduct){
        return workflowProductService.updateById(workflowProduct);
    }

    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable("id") Long id){
        return workflowProductService.deleteById(id);
    }

    @DeleteMapping("/batchDelete")
    public Result batchDelete(Long[] id){
        return workflowProductService.batchDelete(id);
    }
}
